package com.moyu.crowdsource.controller;

import com.moyu.crowdsource.entity.CommodityImage;
import com.moyu.crowdsource.service.CommodityImageService;
import com.moyu.crowdsource.service.OSSService;
import com.moyu.crowdsource.util.Msg;
import com.moyu.crowdsource.util.MyUUID;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;

@Api(
  value = "订单图片controller",
  tags = {"订单图片管理"}
)
@RestController
@RequestMapping("${api.base}/commodityimage")
public class CommodityImageController {

  @Autowired CommodityImageService commodityImageService;

  @ApiOperation("获取订单图片")
  @GetMapping("/getimage/{orderId}")
  public Msg getImageByOrderId(@PathVariable("orderId") String orderId) {
    return Msg.success().add("images", commodityImageService.getImageByOrderId(orderId));
  }

  @ApiOperation("商品图片上传")
  @PostMapping("/upload")
  public Msg handleFormUpload(MultipartFile multfile, CommodityImage commodityImage) {
    return commodityImageService.handleFormUpload(multfile,commodityImage);
  }


}
